import { PageOptions, usePageContext, usePageRouter } from '@graphcommerce/framer-next-pages' import { AppShellTitle, Button, iconPersonAlt, Stepper, Title } from '@graphcommerce/next-ui' import { Container, Divider, List, ListItem, NoSsr, Typography } from '@material-ui/core' import { m } from 'framer-motion' import PageLink from 'next/link' import React, { useState } from 'react' import MinimalPageShell, { MinimalPageShellProps, } from '../../../components/AppShell/MinimalPageShell' import PageShellHeader from '../../../components/AppShell/PageShellHeader' type AppShellDemoProps = { baseUrl: string Header: React.FC<{ primary?: React.ReactNode divider?: React.ReactNode hideDragIndicator?: boolean }> } export function AppShellDemo(props: AppShellDemoProps) { const { baseUrl, Header } = props const queryParams = usePageRouter().asPath.split('/') const urlParts = queryParams.pop()?.split('-') ?? [] const title = urlParts.map((s) => `${s?.charAt(0).toUpperCase() + s?.slice(1)}`).join(' ') const [scroll, setScroll] = useState(true) const { backSteps } = usePageContext() const withPrimary = urlParts.includes('primary') const withStepper = urlParts.includes('stepper') const step = Number(urlParts[urlParts.length - 1]) const withIcon = urlParts.includes('icon') const withTitle = urlParts.includes('title') const isLeftSidebarDrawer = urlParts.includes('left') || queryParams.includes('left') const isSidebarDrawer = isLeftSidebarDrawer || urlParts.includes('right') || queryParams.includes('right') const isSheet = queryParams.includes('sheet') const isMinimal = urlParts.includes('minimal') || queryParams.includes('minimal-page-shell') const isMinimalPageShellSubheader = urlParts.includes('subheader') || queryParams.includes('minimal-page-shell-subheader') const isFullPage = !isSheet && !isMinimal && !isMinimalPageShellSubheader let primaryAction: React.ReactNode if (withPrimary) primaryAction = ( ) if (withStepper && step < 3) { primaryAction = ( ) } let titleComponent = ( {title} ) if (withIcon) titleComponent = ( {title} ) return ( <>
) : undefined } hideDragIndicator={isSidebarDrawer} > {isMinimal || isSheet || withTitle ? titleComponent : undefined}
{title} {isSheet && !primaryAction && ( When opening a sheet a close icon is shown at the top right. )} {primaryAction && backSteps === 0 && ( When a primary action is present, the close button moves to the left. )} {backSteps > 0 && ( When navigated inside the overlay, a backbutton is shown on in the top left. )} {primaryAction && backSteps > 0 && ( With a primary action and back button, there is no room for the close button. The close button gets ommited )} {!!primaryAction || (backSteps === 0 && ( Navigate ))} With primary action With stepper With icon Bottom sheet Left side sheet Right side sheet Minimal Page Shell Full Page Shell Full Page Shell + Title Minimal Page Shell + Subheader setScroll(!scroll)} color='secondary' style={{ paddingLeft: 0, paddingRight: 0 }} > {scroll ? 'Make unscrollable' : 'Make scrollable'}
) } function MinimalPageShellDemo() { return } const pageOptions: PageOptions = { SharedComponent: MinimalPageShell, } MinimalPageShellDemo.pageOptions = pageOptions export default MinimalPageShellDemo